// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Ingest;

public sealed partial class AttachmentProcessor
{
	/// <summary>
	/// <para>Description of the processor.<br/>Useful for describing the purpose of the processor or its configuration.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("description")]
	public string? Description { get; set; }

	/// <summary>
	/// <para>The field to get the base64 encoded field from.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("field")]
	public Elastic.Clients.Elasticsearch.Field Field { get; set; }

	/// <summary>
	/// <para>Conditionally execute the processor.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("if")]
	public string? If { get; set; }

	/// <summary>
	/// <para>Ignore failures for the processor.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_failure")]
	public bool? IgnoreFailure { get; set; }

	/// <summary>
	/// <para>If `true` and field does not exist, the processor quietly exits without modifying the document.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_missing")]
	public bool? IgnoreMissing { get; set; }

	/// <summary>
	/// <para>The number of chars being used for extraction to prevent huge fields.<br/>Use `-1` for no limit.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("indexed_chars")]
	public long? IndexedChars { get; set; }

	/// <summary>
	/// <para>Field name from which you can overwrite the number of chars being used for extraction.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("indexed_chars_field")]
	public Elastic.Clients.Elasticsearch.Field? IndexedCharsField { get; set; }

	/// <summary>
	/// <para>Handle failures for the processor.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("on_failure")]
	public ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? OnFailure { get; set; }

	/// <summary>
	/// <para>Array of properties to select to be stored.<br/>Can be `content`, `title`, `name`, `author`, `keywords`, `date`, `content_type`, `content_length`, `language`.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("properties")]
	public ICollection<string>? Properties { get; set; }

	/// <summary>
	/// <para>If true, the binary field will be removed from the document</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("remove_binary")]
	public bool? RemoveBinary { get; set; }

	/// <summary>
	/// <para>Field containing the name of the resource to decode.<br/>If specified, the processor passes this resource name to the underlying Tika library to enable Resource Name Based Detection.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("resource_name")]
	public string? ResourceName { get; set; }

	/// <summary>
	/// <para>Identifier for the processor.<br/>Useful for debugging and metrics.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("tag")]
	public string? Tag { get; set; }

	/// <summary>
	/// <para>The field that will hold the attachment information.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("target_field")]
	public Elastic.Clients.Elasticsearch.Field? TargetField { get; set; }

	public static implicit operator Elastic.Clients.Elasticsearch.Ingest.Processor(AttachmentProcessor attachmentProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Attachment(attachmentProcessor);
}

public sealed partial class AttachmentProcessorDescriptor<TDocument> : SerializableDescriptor<AttachmentProcessorDescriptor<TDocument>>
{
	internal AttachmentProcessorDescriptor(Action<AttachmentProcessorDescriptor<TDocument>> configure) => configure.Invoke(this);

	public AttachmentProcessorDescriptor() : base()
	{
	}

	private string? DescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }
	private string? IfValue { get; set; }
	private bool? IgnoreFailureValue { get; set; }
	private bool? IgnoreMissingValue { get; set; }
	private long? IndexedCharsValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field? IndexedCharsFieldValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? OnFailureValue { get; set; }
	private Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument> OnFailureDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>> OnFailureDescriptorAction { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>>[] OnFailureDescriptorActions { get; set; }
	private ICollection<string>? PropertiesValue { get; set; }
	private bool? RemoveBinaryValue { get; set; }
	private string? ResourceNameValue { get; set; }
	private string? TagValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field? TargetFieldValue { get; set; }

	/// <summary>
	/// <para>Description of the processor.<br/>Useful for describing the purpose of the processor or its configuration.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>The field to get the base64 encoded field from.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> Field(Elastic.Clients.Elasticsearch.Field field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>The field to get the base64 encoded field from.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> Field<TValue>(Expression<Func<TDocument, TValue>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>The field to get the base64 encoded field from.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> Field(Expression<Func<TDocument, object>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>Conditionally execute the processor.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> If(string? value)
	{
		IfValue = value;
		return Self;
	}

	/// <summary>
	/// <para>Ignore failures for the processor.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> IgnoreFailure(bool? ignoreFailure = true)
	{
		IgnoreFailureValue = ignoreFailure;
		return Self;
	}

	/// <summary>
	/// <para>If `true` and field does not exist, the processor quietly exits without modifying the document.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> IgnoreMissing(bool? ignoreMissing = true)
	{
		IgnoreMissingValue = ignoreMissing;
		return Self;
	}

	/// <summary>
	/// <para>The number of chars being used for extraction to prevent huge fields.<br/>Use `-1` for no limit.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> IndexedChars(long? indexedChars)
	{
		IndexedCharsValue = indexedChars;
		return Self;
	}

	/// <summary>
	/// <para>Field name from which you can overwrite the number of chars being used for extraction.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> IndexedCharsField(Elastic.Clients.Elasticsearch.Field? indexedCharsField)
	{
		IndexedCharsFieldValue = indexedCharsField;
		return Self;
	}

	/// <summary>
	/// <para>Field name from which you can overwrite the number of chars being used for extraction.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> IndexedCharsField<TValue>(Expression<Func<TDocument, TValue>> indexedCharsField)
	{
		IndexedCharsFieldValue = indexedCharsField;
		return Self;
	}

	/// <summary>
	/// <para>Field name from which you can overwrite the number of chars being used for extraction.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> IndexedCharsField(Expression<Func<TDocument, object>> indexedCharsField)
	{
		IndexedCharsFieldValue = indexedCharsField;
		return Self;
	}

	/// <summary>
	/// <para>Handle failures for the processor.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> OnFailure(ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? onFailure)
	{
		OnFailureDescriptor = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = null;
		OnFailureValue = onFailure;
		return Self;
	}

	public AttachmentProcessorDescriptor<TDocument> OnFailure(Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument> descriptor)
	{
		OnFailureValue = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = null;
		OnFailureDescriptor = descriptor;
		return Self;
	}

	public AttachmentProcessorDescriptor<TDocument> OnFailure(Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>> configure)
	{
		OnFailureValue = null;
		OnFailureDescriptor = null;
		OnFailureDescriptorActions = null;
		OnFailureDescriptorAction = configure;
		return Self;
	}

	public AttachmentProcessorDescriptor<TDocument> OnFailure(params Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>>[] configure)
	{
		OnFailureValue = null;
		OnFailureDescriptor = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = configure;
		return Self;
	}

	/// <summary>
	/// <para>Array of properties to select to be stored.<br/>Can be `content`, `title`, `name`, `author`, `keywords`, `date`, `content_type`, `content_length`, `language`.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> Properties(ICollection<string>? properties)
	{
		PropertiesValue = properties;
		return Self;
	}

	/// <summary>
	/// <para>If true, the binary field will be removed from the document</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> RemoveBinary(bool? removeBinary = true)
	{
		RemoveBinaryValue = removeBinary;
		return Self;
	}

	/// <summary>
	/// <para>Field containing the name of the resource to decode.<br/>If specified, the processor passes this resource name to the underlying Tika library to enable Resource Name Based Detection.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> ResourceName(string? resourceName)
	{
		ResourceNameValue = resourceName;
		return Self;
	}

	/// <summary>
	/// <para>Identifier for the processor.<br/>Useful for debugging and metrics.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> Tag(string? tag)
	{
		TagValue = tag;
		return Self;
	}

	/// <summary>
	/// <para>The field that will hold the attachment information.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> TargetField(Elastic.Clients.Elasticsearch.Field? targetField)
	{
		TargetFieldValue = targetField;
		return Self;
	}

	/// <summary>
	/// <para>The field that will hold the attachment information.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> TargetField<TValue>(Expression<Func<TDocument, TValue>> targetField)
	{
		TargetFieldValue = targetField;
		return Self;
	}

	/// <summary>
	/// <para>The field that will hold the attachment information.</para>
	/// </summary>
	public AttachmentProcessorDescriptor<TDocument> TargetField(Expression<Func<TDocument, object>> targetField)
	{
		TargetFieldValue = targetField;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		writer.WritePropertyName("field");
		JsonSerializer.Serialize(writer, FieldValue, options);
		if (!string.IsNullOrEmpty(IfValue))
		{
			writer.WritePropertyName("if");
			writer.WriteStringValue(IfValue);
		}

		if (IgnoreFailureValue.HasValue)
		{
			writer.WritePropertyName("ignore_failure");
			writer.WriteBooleanValue(IgnoreFailureValue.Value);
		}

		if (IgnoreMissingValue.HasValue)
		{
			writer.WritePropertyName("ignore_missing");
			writer.WriteBooleanValue(IgnoreMissingValue.Value);
		}

		if (IndexedCharsValue.HasValue)
		{
			writer.WritePropertyName("indexed_chars");
			writer.WriteNumberValue(IndexedCharsValue.Value);
		}

		if (IndexedCharsFieldValue is not null)
		{
			writer.WritePropertyName("indexed_chars_field");
			JsonSerializer.Serialize(writer, IndexedCharsFieldValue, options);
		}

		if (OnFailureDescriptor is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, OnFailureDescriptor, options);
			writer.WriteEndArray();
		}
		else if (OnFailureDescriptorAction is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>(OnFailureDescriptorAction), options);
			writer.WriteEndArray();
		}
		else if (OnFailureDescriptorActions is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			foreach (var action in OnFailureDescriptorActions)
			{
				JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor<TDocument>(action), options);
			}

			writer.WriteEndArray();
		}
		else if (OnFailureValue is not null)
		{
			writer.WritePropertyName("on_failure");
			JsonSerializer.Serialize(writer, OnFailureValue, options);
		}

		if (PropertiesValue is not null)
		{
			writer.WritePropertyName("properties");
			JsonSerializer.Serialize(writer, PropertiesValue, options);
		}

		if (RemoveBinaryValue.HasValue)
		{
			writer.WritePropertyName("remove_binary");
			writer.WriteBooleanValue(RemoveBinaryValue.Value);
		}

		if (!string.IsNullOrEmpty(ResourceNameValue))
		{
			writer.WritePropertyName("resource_name");
			writer.WriteStringValue(ResourceNameValue);
		}

		if (!string.IsNullOrEmpty(TagValue))
		{
			writer.WritePropertyName("tag");
			writer.WriteStringValue(TagValue);
		}

		if (TargetFieldValue is not null)
		{
			writer.WritePropertyName("target_field");
			JsonSerializer.Serialize(writer, TargetFieldValue, options);
		}

		writer.WriteEndObject();
	}
}

public sealed partial class AttachmentProcessorDescriptor : SerializableDescriptor<AttachmentProcessorDescriptor>
{
	internal AttachmentProcessorDescriptor(Action<AttachmentProcessorDescriptor> configure) => configure.Invoke(this);

	public AttachmentProcessorDescriptor() : base()
	{
	}

	private string? DescriptionValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field FieldValue { get; set; }
	private string? IfValue { get; set; }
	private bool? IgnoreFailureValue { get; set; }
	private bool? IgnoreMissingValue { get; set; }
	private long? IndexedCharsValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field? IndexedCharsFieldValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? OnFailureValue { get; set; }
	private Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor OnFailureDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor> OnFailureDescriptorAction { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor>[] OnFailureDescriptorActions { get; set; }
	private ICollection<string>? PropertiesValue { get; set; }
	private bool? RemoveBinaryValue { get; set; }
	private string? ResourceNameValue { get; set; }
	private string? TagValue { get; set; }
	private Elastic.Clients.Elasticsearch.Field? TargetFieldValue { get; set; }

	/// <summary>
	/// <para>Description of the processor.<br/>Useful for describing the purpose of the processor or its configuration.</para>
	/// </summary>
	public AttachmentProcessorDescriptor Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>The field to get the base64 encoded field from.</para>
	/// </summary>
	public AttachmentProcessorDescriptor Field(Elastic.Clients.Elasticsearch.Field field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>The field to get the base64 encoded field from.</para>
	/// </summary>
	public AttachmentProcessorDescriptor Field<TDocument, TValue>(Expression<Func<TDocument, TValue>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>The field to get the base64 encoded field from.</para>
	/// </summary>
	public AttachmentProcessorDescriptor Field<TDocument>(Expression<Func<TDocument, object>> field)
	{
		FieldValue = field;
		return Self;
	}

	/// <summary>
	/// <para>Conditionally execute the processor.</para>
	/// </summary>
	public AttachmentProcessorDescriptor If(string? value)
	{
		IfValue = value;
		return Self;
	}

	/// <summary>
	/// <para>Ignore failures for the processor.</para>
	/// </summary>
	public AttachmentProcessorDescriptor IgnoreFailure(bool? ignoreFailure = true)
	{
		IgnoreFailureValue = ignoreFailure;
		return Self;
	}

	/// <summary>
	/// <para>If `true` and field does not exist, the processor quietly exits without modifying the document.</para>
	/// </summary>
	public AttachmentProcessorDescriptor IgnoreMissing(bool? ignoreMissing = true)
	{
		IgnoreMissingValue = ignoreMissing;
		return Self;
	}

	/// <summary>
	/// <para>The number of chars being used for extraction to prevent huge fields.<br/>Use `-1` for no limit.</para>
	/// </summary>
	public AttachmentProcessorDescriptor IndexedChars(long? indexedChars)
	{
		IndexedCharsValue = indexedChars;
		return Self;
	}

	/// <summary>
	/// <para>Field name from which you can overwrite the number of chars being used for extraction.</para>
	/// </summary>
	public AttachmentProcessorDescriptor IndexedCharsField(Elastic.Clients.Elasticsearch.Field? indexedCharsField)
	{
		IndexedCharsFieldValue = indexedCharsField;
		return Self;
	}

	/// <summary>
	/// <para>Field name from which you can overwrite the number of chars being used for extraction.</para>
	/// </summary>
	public AttachmentProcessorDescriptor IndexedCharsField<TDocument, TValue>(Expression<Func<TDocument, TValue>> indexedCharsField)
	{
		IndexedCharsFieldValue = indexedCharsField;
		return Self;
	}

	/// <summary>
	/// <para>Field name from which you can overwrite the number of chars being used for extraction.</para>
	/// </summary>
	public AttachmentProcessorDescriptor IndexedCharsField<TDocument>(Expression<Func<TDocument, object>> indexedCharsField)
	{
		IndexedCharsFieldValue = indexedCharsField;
		return Self;
	}

	/// <summary>
	/// <para>Handle failures for the processor.</para>
	/// </summary>
	public AttachmentProcessorDescriptor OnFailure(ICollection<Elastic.Clients.Elasticsearch.Ingest.Processor>? onFailure)
	{
		OnFailureDescriptor = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = null;
		OnFailureValue = onFailure;
		return Self;
	}

	public AttachmentProcessorDescriptor OnFailure(Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor descriptor)
	{
		OnFailureValue = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = null;
		OnFailureDescriptor = descriptor;
		return Self;
	}

	public AttachmentProcessorDescriptor OnFailure(Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor> configure)
	{
		OnFailureValue = null;
		OnFailureDescriptor = null;
		OnFailureDescriptorActions = null;
		OnFailureDescriptorAction = configure;
		return Self;
	}

	public AttachmentProcessorDescriptor OnFailure(params Action<Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor>[] configure)
	{
		OnFailureValue = null;
		OnFailureDescriptor = null;
		OnFailureDescriptorAction = null;
		OnFailureDescriptorActions = configure;
		return Self;
	}

	/// <summary>
	/// <para>Array of properties to select to be stored.<br/>Can be `content`, `title`, `name`, `author`, `keywords`, `date`, `content_type`, `content_length`, `language`.</para>
	/// </summary>
	public AttachmentProcessorDescriptor Properties(ICollection<string>? properties)
	{
		PropertiesValue = properties;
		return Self;
	}

	/// <summary>
	/// <para>If true, the binary field will be removed from the document</para>
	/// </summary>
	public AttachmentProcessorDescriptor RemoveBinary(bool? removeBinary = true)
	{
		RemoveBinaryValue = removeBinary;
		return Self;
	}

	/// <summary>
	/// <para>Field containing the name of the resource to decode.<br/>If specified, the processor passes this resource name to the underlying Tika library to enable Resource Name Based Detection.</para>
	/// </summary>
	public AttachmentProcessorDescriptor ResourceName(string? resourceName)
	{
		ResourceNameValue = resourceName;
		return Self;
	}

	/// <summary>
	/// <para>Identifier for the processor.<br/>Useful for debugging and metrics.</para>
	/// </summary>
	public AttachmentProcessorDescriptor Tag(string? tag)
	{
		TagValue = tag;
		return Self;
	}

	/// <summary>
	/// <para>The field that will hold the attachment information.</para>
	/// </summary>
	public AttachmentProcessorDescriptor TargetField(Elastic.Clients.Elasticsearch.Field? targetField)
	{
		TargetFieldValue = targetField;
		return Self;
	}

	/// <summary>
	/// <para>The field that will hold the attachment information.</para>
	/// </summary>
	public AttachmentProcessorDescriptor TargetField<TDocument, TValue>(Expression<Func<TDocument, TValue>> targetField)
	{
		TargetFieldValue = targetField;
		return Self;
	}

	/// <summary>
	/// <para>The field that will hold the attachment information.</para>
	/// </summary>
	public AttachmentProcessorDescriptor TargetField<TDocument>(Expression<Func<TDocument, object>> targetField)
	{
		TargetFieldValue = targetField;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		writer.WritePropertyName("field");
		JsonSerializer.Serialize(writer, FieldValue, options);
		if (!string.IsNullOrEmpty(IfValue))
		{
			writer.WritePropertyName("if");
			writer.WriteStringValue(IfValue);
		}

		if (IgnoreFailureValue.HasValue)
		{
			writer.WritePropertyName("ignore_failure");
			writer.WriteBooleanValue(IgnoreFailureValue.Value);
		}

		if (IgnoreMissingValue.HasValue)
		{
			writer.WritePropertyName("ignore_missing");
			writer.WriteBooleanValue(IgnoreMissingValue.Value);
		}

		if (IndexedCharsValue.HasValue)
		{
			writer.WritePropertyName("indexed_chars");
			writer.WriteNumberValue(IndexedCharsValue.Value);
		}

		if (IndexedCharsFieldValue is not null)
		{
			writer.WritePropertyName("indexed_chars_field");
			JsonSerializer.Serialize(writer, IndexedCharsFieldValue, options);
		}

		if (OnFailureDescriptor is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, OnFailureDescriptor, options);
			writer.WriteEndArray();
		}
		else if (OnFailureDescriptorAction is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor(OnFailureDescriptorAction), options);
			writer.WriteEndArray();
		}
		else if (OnFailureDescriptorActions is not null)
		{
			writer.WritePropertyName("on_failure");
			writer.WriteStartArray();
			foreach (var action in OnFailureDescriptorActions)
			{
				JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Ingest.ProcessorDescriptor(action), options);
			}

			writer.WriteEndArray();
		}
		else if (OnFailureValue is not null)
		{
			writer.WritePropertyName("on_failure");
			JsonSerializer.Serialize(writer, OnFailureValue, options);
		}

		if (PropertiesValue is not null)
		{
			writer.WritePropertyName("properties");
			JsonSerializer.Serialize(writer, PropertiesValue, options);
		}

		if (RemoveBinaryValue.HasValue)
		{
			writer.WritePropertyName("remove_binary");
			writer.WriteBooleanValue(RemoveBinaryValue.Value);
		}

		if (!string.IsNullOrEmpty(ResourceNameValue))
		{
			writer.WritePropertyName("resource_name");
			writer.WriteStringValue(ResourceNameValue);
		}

		if (!string.IsNullOrEmpty(TagValue))
		{
			writer.WritePropertyName("tag");
			writer.WriteStringValue(TagValue);
		}

		if (TargetFieldValue is not null)
		{
			writer.WritePropertyName("target_field");
			JsonSerializer.Serialize(writer, TargetFieldValue, options);
		}

		writer.WriteEndObject();
	}
}